package src.test;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ThreadServer extends Thread
{

	public void run()
	{
		Socket comm = null;
		ServerSocket conn = null;
		InputStream is = null;
		boolean bool=true;
		  
	    try
	    {
	     while(bool==true)
		  {
	    	 conn = new ServerSocket(8070);
	    	 comm = conn.accept();	 
	    	 is = comm.getInputStream();
	   
	    	 int c;
	    	 while((c = is.read()) != -1)
	    	 {
	    		 System.out.write(c);
	    	 }
	      
	      }
//	      comm.getOutputStream().write("Bonjour client 1".getBytes());
//	      comm.getOutputStream().write("Bonjour client 2".getBytes());


	    }
	    catch(Exception e)
	    {
	    	System.err.println("Exception " + e.toString());
	    }
	    finally
	    {
	    	if (is!=null)
				try {
					is.close();
				} catch (IOException e) {e.printStackTrace();}
			if (comm!=null)
				try {
					comm.close();
				} catch (IOException e) {e.printStackTrace();}
			if (conn!=null)
				try {
					conn.close();
				} catch (IOException e) {e.printStackTrace();}
	    }
	}
}
